<?php

namespace app\admin\model\plan;

use think\Model;


class User extends Model
{

    

    

    // 表名
    protected $name = 'plan_user';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'examine_text'
    ];
    

    
    public function getExamineList()
    {
        return ['0' => __('Examine 0'), '1' => __('Examine 1'), '2' => __('Examine 2')];
    }


    public function getExamineTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['examine']) ? $data['examine'] : '');
        $list = $this->getExamineList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function users()
    {
        return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }

    public function plan()
    {
        return $this->belongsTo('app\admin\model\Plan', 'p_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
